package cn.javass.framework.web.core;

import cn.javass.framework.web.annotation.IAction;
import cn.javass.framework.web.config.ActionMapper;
import cn.javass.framework.web.config.Configuration;

public class DefaultApplicationController implements ApplicationController{
	
	public  ActionInvocation newActionInvocation(String path) throws Exception{
		ActionMapper am = Configuration.getActionMapper(path);
		ActionInvocation actionInvocation = new ActionInvocation();
		actionInvocation.setAction((Action) am.getActionClass().newInstance());
		actionInvocation.setInterceptors(am.getInterceptors());
		return actionInvocation;
	}
	
	public  String getResult(Action action,String resultKey){
		ActionMapper am = Configuration.getActionMapper(((IAction)action.getClass().getAnnotation(IAction.class)).path());
		String path = am.getGotos().get(resultKey);
		return path;
	}
}
